#include <bits/stdc++.h>
using namespace std;


/**
 * 
 * 时间复杂度：O(t*n)
 * 空间复杂度：O(n)
 * 
 * 卡片游戏
 * 
 */
int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        if (n == 1) {
            cout << 1 << endl;
            continue;
        }
        queue<int> q;
        for (int i = 1; i <= n; i++) {
            q.push(i);
        }
        while (q.size() > 2) {
            cout << q.front() << ' ';
            q.pop();
            q.push(q.front());
            q.pop();
        }
        cout << q.front() << ' ';
        q.pop();
        cout << q.front() << endl;
    }
    return 0;
}